package com.module.admin.log.service.impl;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

import com.module.admin.log.dao.BizLogDtlDao;
import com.module.admin.log.pojo.BizLogDtl;
import com.module.admin.log.service.BizLogDtlService;
import com.system.comm.model.Page;
import com.system.comm.utils.FrameNoUtil;
import com.system.handle.model.ResponseCode;
import com.system.handle.model.ResponseFrame;

/**
 * biz_log_dtl的Service
 * @author admin
 * @date 2019-11-29 10:57:13
 * @version V1.0.0
 */
@Component
public class BizLogDtlServiceImpl implements BizLogDtlService {

	@Autowired
	private BizLogDtlDao bizLogDtlDao;
	
	/**
	 * 保存
	 * @param bizLogDtl
	 * @return
	 */
	@Override
	public ResponseFrame save(BizLogDtl bizLogDtl) {
		ResponseFrame frame = new ResponseFrame();
		bizLogDtl.setBldId(FrameNoUtil.uuid());
		bizLogDtlDao.save(bizLogDtl);
		frame.setCode(ResponseCode.SUCC.getCode());
		return frame;
	}
	
	/**
	 * 根据bldId获取对象
	 * @param bldId
	 * @return
	 */
	@Override
	public BizLogDtl get(String bldId) {
		return bizLogDtlDao.get(bldId);
	}

	/**
	 * 分页获取对象
	 * @param bizLogDtl
	 * @return
	 */
	@Override
	public ResponseFrame pageQuery(BizLogDtl bizLogDtl) {
		bizLogDtl.setDefPageSize();
		ResponseFrame frame = new ResponseFrame();
		int total = bizLogDtlDao.findBizLogDtlCount(bizLogDtl);
		List<BizLogDtl> data = null;
		if(total > 0) {
			data = bizLogDtlDao.findBizLogDtl(bizLogDtl);
		}
		Page<BizLogDtl> page = new Page<BizLogDtl>(bizLogDtl.getPage(), bizLogDtl.getSize(), total, data);
		frame.setBody(page);
		frame.setCode(ResponseCode.SUCC.getCode());
		return frame;
	}
	
	/**
	 * 根据bldId删除对象
	 * @param bldId
	 * @return
	 */
	@Override
	public ResponseFrame delete(String bldId) {
		ResponseFrame frame = new ResponseFrame();
		bizLogDtlDao.delete(bldId);
		frame.setCode(ResponseCode.SUCC.getCode());
		return frame;
	}

	@Override
	public List<BizLogDtl> findByTraceId(String traceId) {
		return bizLogDtlDao.findByTraceId(traceId);
	}
}